package com.raos.quartz.second;

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

/**
 * JobDataMap 方法测试
 *
 * @author raos
 * @email 991207823@qq.com
 * @date 2021/10/01 20:10
 */
public class SecondScheduler {

    public static void main(String[] args) throws SchedulerException {
        // 创建一个jobDetail的实例
        JobDetail jobDetail = JobBuilder.newJob(SecondJob.class)
                .withIdentity("myJob", "group1")
                .usingJobData("message", "hello myJob1")
                .usingJobData("FloatJobValue", 8.88f)
                .build();

        // 创建一个Trigger触发器的实例
        CronTrigger trigger = TriggerBuilder.newTrigger()
                .withIdentity("myTrigger", "group1")
                .withSchedule(CronScheduleBuilder.cronSchedule("0/5 * * * * ? "))
                .build();
        // 创建schedule实例
        StdSchedulerFactory factory = new StdSchedulerFactory();
        Scheduler scheduler = factory.getScheduler();
        scheduler.start();
        scheduler.scheduleJob(jobDetail, trigger);
    }

}
